/**
 * 转账流程状态
 */
export const state = () => {
  let status = sessionStorage.getItem("pay-status");

  try {
    status = JSON.parse(status);
  } catch (e) {
    status = null;
  }
  return {
    status,
  }
}

export const mutations = {
  setStatus(state, status) {
    if (status) {
      sessionStorage.setItem("pay-status", JSON.stringify(status));
    } else {
      sessionStorage.removeItem("pay-status");
    }
    state.status = status || null
  },
}

export const actions = {
  clear({
    commit
  }) { // 清楚所有状态
    commit('setStatus', null)
  },
}
